package jp.co.systemi.asp.utils;

import java.lang.reflect.Field;
import java.util.logging.Logger;

public class BeanUtils {
    private static final Logger log = Logger.getLogger(BeanUtils.class.getName());
    static public <T> void copy(T dest, T src) {
        for (Field fld : src.getClass().getDeclaredFields()) {
            try {
                fld.setAccessible(true);
                Object val = fld.get(src);
                fld.set(dest, val);
                log.info("set field: " + fld.getName());
            } catch (IllegalArgumentException e) {
                log.info(e.getLocalizedMessage());
            } catch (IllegalAccessException e) {
                log.info(e.getLocalizedMessage());
            }
        }

    }
}
